package com.game.server.message.proto.execute;

import com.comm.ISession;

import com.game.majiang.logic.LogicClient;
import com.game.majiang.logic.LogicServer;
import com.game.majiang.logic.LogicTable;
import com.game.server.message.proto.in.AbstractChatReq;
import com.game.server.message.proto.out.ChatRsp;
import com.game.server.system.AbstractTable;

public class ChatReq extends AbstractChatReq {

    @Override
    public void Execute(ISession session) {
        LogicClient client = (LogicClient) LogicServer.getInstance().getClient(session.getId());
        if (client != null&&client.checkClick(msgcode)) {
        	AbstractTable abTable = client.getTable();
        	if(abTable != null) {
        		LogicTable table = (LogicTable) abTable;
        		if(table.isForbidChat()) {
        			ChatRsp rsp = new ChatRsp();
            		rsp.setAcceptUid(this.acceptUid);
            		rsp.setContent(this.content);
            		rsp.setType(this.type);
            		rsp.setUid(client.getUserId());
            		table.BroadCast(rsp, 2);
            		if(this.type.intValue() == 0) {
            			table.addListChat(client.getVo().getNickName()+ ":" + this.content);
            		}	
        		}
        	}
        }
    }

}
